#-*-coding:utf-8-*-
import os
import hou

class Open(object):
    def __init__(self):
        super(Open,self).__init__()

    def openHoudini(self):
        '''
        建议设置houdini的环境变量  比如HOU_EXE"C:/Program Files/Side Effects Software/Houdini "+version+"/bin/houdini.exe"

        :return:
        '''
        houdiniPath=hou.getenv("HOU_EXE")
        try:
            os.startfile(houdiniPath)
        except:
            print('请设置HOUDINI_EXE_PATH路径').encode('gbk')
        # print('OK')

    def openHoudinibyPath(self,houdiniExePath):
        '''
        通过指定路径打开houdini.exe
        :param houdiniPath:
        :return:
        '''
        try:
            os.startfile(houdiniExePath)
        except:
            print('houdini exe路径错误').encode('gbk')
        # print('OK')



    def openMaya(self):
        '''
        通过预设环境变量打开maya
        :return:
        '''
        mayaPath=hou.getenv("MAYA_EXE")
        try:
            os.startfile(mayaPath)
        except:
            print('请设置MAYA_EXE_PATH路径').encode('gbk')



    def openMayaByPath(self,mayaExePath):
        '''
        指定maya.exe路径
        :param mayaExePath:
        :return:
        '''
        try:
            os.startfile(mayaExePath)
        except:
            print('maya exe路径错误').encode('gbk')
        # print('OK')



    def openNuke(self):
        '''
        通过预设环境变量打开nuke
        :return:
        '''
        nukePath=hou.getenv("NUKE_EXE")
        try:
            os.startfile(nukePath)
        except:
            print('请设置NUKE_EXE_PATH路径').encode('gbk')



    def openNukeByPath(self,nukeExePath):
        '''
        指定nuke.exe路径
        :param nukeExePath:
        :return:
        '''
        try:
            os.startfile(nukeExePath)
        except:
            print('nuke exe路径错误').encode('gbk')
        # print('OK')





    def openDisk(self,diskPath):
        '''
        打开盘符：
        比如C盘：diskpath='c:' 或者 'C:'
        :param diskpath: 可以为文件夹路径
        比如打开文件夹 C:\Windows   diskpath='C:\Windows'

        :return:
        '''
        os.system("explorer.exe %s" % diskPath)




    def showInExplore(self):
        p = hou.expandString('$HIP')
        rp = p.replace("/", "\\")
        os.popen(r"explorer.exe  %s" % rp)